package cn.com.cfae.iras.doc.analyze.parse;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexUtil {

    private static Logger logger = LoggerFactory.getLogger(RegexUtil.class);
    public static final String SY_FORMAT = "((\\s+指)|(\\s{1,}))";
    public static final String FXTK_FORMAT = "((\\s{0,}\\:{1}\\s{0,})|(\\s{1,}))";
    public static final String FXR_FORMAT = FXTK_FORMAT;
    public static final String DEFAULT_KV_FORMAT = "((\\s{1,})|(\\s{0,}\\:{1}\\s{0,}))";
    public static String CWBB_NB_FORMAT = "((20\\d{2}\\-{1}20\\d{2}\\s{0,}[年]{1})|(20\\d{2}\\s{0,}年至\\s{0,}20\\d{2}\\s{0,}年)|(20\\d{2}\\s{0,}[年]{1}\\-{1}20\\d{2}\\s{0,}[年]{1})|(20\\d{2}\\s{0,}年[一二三四]季度))";
    public static String CWBB_JB_FORMAT = "20\\d{2}\\s{0,}年\\s{0,}\\d{1,2}\\-{0,1}\\d{0,2}\\s{0,}月{1}";
    public static String CWBB_JSNJYQ_FORMAT = "(近三年及一期|近三年一期|近三年又一期)";
    public static String CWBB_KJKM_AMT_FORMAT = "((\\-?([0-9]{0,3}\\,{0,}){0,}([0-9]{1,3}){1,}\\.{0,}[0-9]{2})\\s{0,}(亿元|万元){1})";
    public static String HYZB_MT_MTCL_FORMAT = "((([0-9]{0,3}\\,{0,}){0,}([0-9]{1,3}){1,}\\.{0,}[0-9]{2})\\s{0,}(万吨|亿吨|Mt){1})";
    public static String HYZB_MT_XSJG_FORMAT = "((([0-9]{0,3}\\,{0,}){0,}([0-9]{1,3}){1,}\\.{0,}[0-9]{2})\\s{0,}(元/吨){1})";
    public String FXJG_SPLIT_FORMAT = "((\\s{0,}\\:{1}\\s{0,})|(\\s{1,}))";

    public boolean isSY_Format(String text) {
        String regex = SY_FORMAT;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.find()) {
            return true;
        }
        return false;
    }


    public String findSY_Format_Split_Char(String text) {
        String regex = SY_FORMAT;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.find()) {
            return matcher.group();
        }
        return ":";//默认返回冒号，按理说不应该这么干
    }


    public boolean isFXTK_Format(String text) {
        text = text.replaceAll("^\\d{1,2}[、.]?", "").trim();
        String regex = FXTK_FORMAT;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.find()) {
            return true;
        }
        return false;
    }

    public boolean isFXJG_SPLIT_Format(String text) {
        text = text.replaceAll("^\\d{1,2}[、.]?", "").trim();
        String regex = FXJG_SPLIT_FORMAT;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.find()) {
            return true;
        }
        return false;
    }

    public boolean isFXR_Format(String text) {
        text = text.replaceAll("^\\d{1,2}[、.]?", "").trim();
        String regex = FXR_FORMAT;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.find()) {
            return true;
        }
        return false;
    }

    public String findFXJG_Format_Split_Char(String text) {
        text = text.replaceAll("^\\d{1,2}[、.]?", "").trim();
        String regex = FXJG_SPLIT_FORMAT;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.find()) {
            return matcher.group();
        }
        return ":";//默认返回冒号，按理说不应该这么干
    }


    public String findFXTK_Format_Split_Char(String text) {
        text = text.replaceAll("^\\d{1,2}[、.]?", "").trim();
        String regex = FXTK_FORMAT;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.find()) {
            return matcher.group();
        }
        return ":";//默认返回冒号，按理说不应该这么干
//        return "";//默认返回冒号，按理说不应该这么干
    }

    public String findDefault_Format_Split_Char(String text) {
        text = text.replaceAll("^\\d{1,2}[、.]?", "").trim();
        String regex = DEFAULT_KV_FORMAT;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.find()) {
            return matcher.group();
        }
        return ":";//默认返回冒号，按理说不应该这么干
    }

    public boolean isDefaultKV(String text) {
//        String regex = "[\\u4E00-\\u9FA5]+\\:\\s{0,}[A-B]{1,}\\+{0,}[\\u4E00-\\u9FA5]{0,}";
//        String regex = "[\\u4E00-\\u9FA5]+\\:\\s{0,}[A-B]{1,}\\+{0,}[\\u4E00-\\u9FA5]{0,}";
//        String regex = "\\d{0,}\\、{0,}\\s{0,}[\\u4E00-\\u9FA5]+\\s{0,}\\:\\s{0,}[A-B]{0,}\\+{0,}\\s{0,}[\\u4E00-\\u9FA5]{0,}\\s{0,}\\({0,}\\s{0,}[\\u4E00-\\u9FA5]{0,}\\){0,}\\s{0,}[0-9]{0,}\\s{0,}[\\u4E00-\\u9FA5]{0,}$";
        String regex = DEFAULT_KV_FORMAT;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.find()) {
            return true;
        }
        return false;
    }

    public boolean isProspectus(String text) {
//        String regex = "^(20)\\d{2}\\s{0,}[\\u0391-\\uFFE5]+[期]{0,}募集说明书+$";
        String regex = "([\\u0391-\\uFFE5]+(\\([\\u0391-\\uFFE5]+\\))?(有限|责任){1,}公司\\s{0,})?((20)\\d{2}([\\-|\\‐]?20\\d{2})?\\s{0,}[\\u0391-\\uFFE5]+[期]{0,}募集说明书$)";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isProspectus2(String keyword) {
//        String regex = "^(20)\\d{2}\\s{0,}[\\u0391-\\uFFE5]+[期]{0,}募集说明书+$";
        String regex = "(募集说明书)";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(keyword);
        if (matcher.find()) {
            return true;
        }
        return false;
    }

    public boolean isCorpName(String text) {
//        String regex = "[\\u0391-\\uFFE5]+(\\([\\u0391-\\uFFE5]+\\))?(有限|责任){1,}公司$";
        String regex = "[\\u0391-\\uFFE5]+(\\([\\u0391-\\uFFE5]+\\))?(有限|责任){1,}公司$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }


    public int calculateChapterLevel(String text) {
        if (isChapterLevel1(text)) {
            return 1;
        }
        if (isChapterLevel2(text)) {
            return 2;
        }
        return 3;//其他
    }

    public boolean isCatalogLevel1(String text) {
//        String regex1 = "^第[一二三四五六七八九十][一二三四]{0,}章\\s{0,}[\\u0391-\\uFFE5]+\\s{0,}\\.{0,}\\s{0,}\\d$";
//        String regex1 = "^第[一二三四五六七八九十][一二三四]{0,}章\\s{0,}[\\u0391-\\uFFE5]+\\s{0,}\\.{0,}\\s{0,}\\d+$";
        String regex_with_prefix = "^第[一二三四五六七八九十]{1,2}章\\s{0,}[\\u0391-\\uFFE5]+\\s{0,}[\\u0391-\\uFFE5]+\\s{0,}\\.{1,}\\s{0,}\\d+$";
//        String regex_no_prefix = "^[\\u0391-\\uFFE5[^\\、]]+\\s{0,}[\\u0391-\\uFFE5]+\\s{0,}\\.{5,}\\s{0,}\\d+$";
        String regex_no_prefix = "[^一二三四五六七八九十]+\\s{0,}[\\u0391-\\uFFE5]+\\s{0,}\\.{5,}\\s{0,}\\d+$";
        Pattern pattern = Pattern.compile(regex_with_prefix);
        Matcher matcher = pattern.matcher(text);
        if (!matcher.matches()) {
            pattern = Pattern.compile(regex_no_prefix);
            matcher = pattern.matcher(text);
            if (matcher.matches()) {
                return true;
            }
            return false;
        }
        return true;
    }

    public boolean isCatalogLevel2(String text) {
        String regex2 = "^[一二三四五六七八九十][一二三四]{0,}\\s{0,}[\\u0391-\\uFFE5]+\\s{0,}\\.{5,}\\s{0,}\\d+$";
        String regex3 = "^\\*[附录]\\s{0,}[\\u0391-\\uFFE5]+\\s{0,}\\.{0,}\\d$";
        Pattern pattern2 = Pattern.compile(regex2);
        Matcher matcher2 = pattern2.matcher(text);
        if (matcher2.matches()) {
            return true;
        }
        return false;
    }

    /**
     * 计算目录层级
     *
     * @param text
     * @return
     */
    public int calculateCatalogLevel(String text) {
        if (isCatalogLevel1(text)) {
            return 1;
        }
        if (isCatalogLevel2(text)) {
            return 2;
        }
        return 3;//其他
    }


    public boolean isChapterLevel1(String text) {
//        String regex1 = "^第[一二三四五六七八九十][一二三四]{0,}章\\s{0,}[\\u0391-\\uFFE5]+$";
        String regex = "^第[一二三四五六七八九十][一二三四]{0,}章\\s{0,}[\\u0391-\\uFFE5]+\\s{0,}[\\u0391-\\uFFE5]+$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.matches()) {
            return true;
        }
        return false;
    }

    /**
     * 熊猫债的目录结构会有些差异，补充熊猫债的目录结构识别
     *
     * @param jsonArray
     * @return
     */
    public boolean isChapterLevel1_2(JsonArray jsonArray, List<String> synonymList) {
        for (int i = 0; i < jsonArray.size(); i++) {
            JsonObject element = jsonArray.get(i).getAsJsonObject();
            String text = element.get("text").getAsString();
            double left = element.get("left").getAsDouble();
            double top = element.get("top").getAsDouble();
            double height = element.get("height").getAsDouble();
            if (500 / 2 < left && height > 7.5 && top <= 100 && synonymList.contains(text)) {
                return true;
            }
        }
        return false;
    }

    public String replaceSpaces(String text) {
        return text = text.replaceAll("\\s+", "");
    }


    public boolean isChapterLevel2(String text) {
//        String regex2 = "^[一二三四五六七八九十][一二三四]{0,}\\s{0,}$";
        String regex = "^[一二三四五六七八九十]{1,2}\\、{1}\\s{0,}[\\u0391-\\uFFE5\\d+\\s?\\-\\(\\)]+\\s{0,}$";
//        String regex = "^[一二三四五六七八九十]{1,2}\\、{0,1}\\s{0,}[\\u0391-\\uFFE5]+\\s{0,}[\\u0391-\\uFFE5]+$";
//        String regex3 = "^\\*[附录]\\s{0,}[\\u0391-\\uFFE5]+\\s{0,}\\.{0,}\\d$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.matches()) {
            return true;
        }
        return false;
    }


    public boolean isChapterLevel3(String text) {
//        String regex2 = "^[一二三四五六七八九十][一二三四]{0,}\\s{0,}$";
        String regex = "((\\({1}[一二三四五六七八九十]{1,2}\\){1})|(\\({0,1}\\d{1,2}\\){0,1}))[\\、|\\.]{0,1}\\s{0,}[\\u0391-\\uFFE5]+\\:{0,1}\\s{0,}$";
//        String regex = "^[一二三四五六七八九十]{1,2}\\、{0,1}\\s{0,}[\\u0391-\\uFFE5]+\\s{0,}[\\u0391-\\uFFE5]+$";
//        String regex3 = "^\\*[附录]\\s{0,}[\\u0391-\\uFFE5]+\\s{0,}\\.{0,}\\d$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.matches()) {
            return true;
        }
        return false;
    }

    public boolean isFXTK(String text) {
//        String regex2 = "^[一二三四五六七八九十][一二三四]{0,}\\s{0,}$";
        String regex2 = "^十一、\\s{0,}[\\u0391-\\uFFE5]+\\s{0,}发行条款\\s{0,1}$";
        String regex3 = "^\\*[附录]\\s{0,}[\\u0391-\\uFFE5]+\\s{0,}\\.{0,}\\d$";
        Pattern pattern2 = Pattern.compile(regex2);
        Matcher matcher2 = pattern2.matcher(text);
        if (matcher2.matches()) {
            return true;
        }
        return false;
    }

    public boolean isFXRJBXX(String text) {
        String regex = "^一、\\s{0,}发行人[\\u0391-\\uFFE5]{0,}\\s{0,}基本[信息|情况]{0,}\\s{0,1}$";
        Pattern pattern2 = Pattern.compile(regex);
        Matcher matcher2 = pattern2.matcher(text);
        if (matcher2.matches()) {
            return true;
        }
        return false;
    }

    public boolean isFXR_SPLIT_BY_COLON(String text) {
//        String regex = "[\\u0391-\\uFFE5]{0,}\\s{0,}\\:\\s{0,}[\\u0391-\\uFFE5]{0,}";
//        Pattern pattern2 = Pattern.compile(regex);
//        Matcher matcher2 = pattern2.matcher(text);
//        if (matcher2.matches()) {
//            return true;
//        }
//        return false;
        if (text.split(":").length > 1) {
            return true;
        }
        return false;
    }

    /**
     * 资产负债
     *
     * @param text
     * @return
     */
    public boolean isZCFZ(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"主要资产负债表", "综合财务状况表", "综合资产负债表", "合并资产负债表", "资产负债表(合并)", "资产负债表\\(合并\\)"};
        String regex = "(^((图)?表\\s{0,}\\d{1,2}\\s?[\\-\\.]{1}\\s?\\d{1,2}(\\s?\\-?\\s?\\d?))|(" + joinSynonyms(synonyms) + ")|(单位))";
        String regex_prefix = "(图)?表\\s{0,}\\d{1,2}\\s?[\\-\\.]{1}\\s?\\d{1,2}(\\s?\\-?\\s?\\d?)";
//        String regex = "(^((图)?表)|(\\d{1,2}\\-{1}\\d{1,2}\\-?\\d?})|(" + joinSynonyms(synonyms) + "))";
        boolean flag1 = false;
        boolean flag2 = false;
        boolean flag3 = false;

        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        List<String> var1 = new ArrayList<>(Arrays.asList(new String[]{"表", "图表"}));
        List<String> var2 = new ArrayList<>(Arrays.asList(synonyms));
        List<String> var3 = new ArrayList<>(Arrays.asList(new String[]{"单位"}));

        while (matcher.find()) {
            String groupName = matcher.group();
            {
                Pattern pattern1 = Pattern.compile(regex_prefix);
                Matcher matcher1 = pattern1.matcher(groupName);
                if (matcher1.matches()) {
                    flag1 = true;
                }
            }
            if (var2.contains(groupName)) {
                flag2 = true;
            }
            if (var3.contains(groupName)) {
                flag3 = true;
            }

        }
        if (flag1 && flag2) {
            return true;
        }

        if (flag2 && flag3) {
            return true;
        }
        return false;
    }

    /**
     * 现金流量
     *
     * @param text
     * @return
     */
    public boolean isXJLL(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"合并现金流量表", "综合现金流量表", "现金流量表(合并)", "现金流量表\\(合并\\)"};
        String regex = "(^((图)?表\\s{0,}\\d{1,2}\\s?[\\-\\.]{1,2}\\s?\\d{1,2}(\\s?\\-?\\s?\\d?))|(" + joinSynonyms(synonyms) + ")|(单位))";
        String regex_prefix = "(图)?表\\s{0,}\\d{1,2}\\s?[\\-\\.]{1,2}\\s?\\d{1,2}(\\s?\\-?\\s?\\d?)";
//        String regex = "(^((图)?表)|(\\d{1,2}\\-{1}\\d{1,2}\\-?\\d?})|(" + joinSynonyms(synonyms) + "))";
        boolean flag1 = false;
        boolean flag2 = false;
        boolean flag3 = false;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        List<String> var1 = new ArrayList<>(Arrays.asList(new String[]{"表", "图表"}));
        List<String> var2 = new ArrayList<>(Arrays.asList(synonyms));
        List<String> var3 = new ArrayList<>(Arrays.asList(new String[]{"单位"}));
        while (matcher.find()) {
            String groupName = matcher.group();
            {
                Pattern pattern1 = Pattern.compile(regex_prefix);
                Matcher matcher1 = pattern1.matcher(groupName);
                if (matcher1.matches()) {
                    flag1 = true;
                }
            }
            if (var2.contains(groupName)) {
                flag2 = true;
            }
            if (var3.contains(groupName)) {
                flag3 = true;
            }
        }
        if (flag1 && flag2) {
            return true;
        }

        if (flag2 && flag3) {
            return true;
        }
        return false;
    }

    /**
     * 利润
     *
     * @param text
     * @return
     */
    public boolean isLR(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"合并利润表", "合并损益表", "合并综合收益表", "综合损益表", "利润表(合并)", "利润表\\(合并\\)"};
        String regex = "(^((图)?表\\s{0,}\\d{1,2}\\s?[\\-\\.]{1}\\s?\\d{1,2}(\\s?\\-?\\s?\\d?))|(" + joinSynonyms(synonyms) + ")|(单位))";
        String regex_prefix = "(图)?表\\s{0,}\\d{1,2}\\s?[\\-\\.]{1}\\s?\\d{1,2}(\\s?\\-?\\s?\\d?)";
//        String regex = "(^((图)?表)|(\\d{1,2}\\-{1}\\d{1,2}\\-?\\d?})|(" + joinSynonyms(synonyms) + "))";
        boolean flag1 = false;
        boolean flag2 = false;
        boolean flag3 = false;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        List<String> var1 = new ArrayList<>(Arrays.asList(new String[]{"表", "图表"}));
        List<String> var2 = new ArrayList<>(Arrays.asList(synonyms));
        List<String> var3 = new ArrayList<>(Arrays.asList(new String[]{"单位"}));
        while (matcher.find()) {
            String groupName = matcher.group();
            {
                Pattern pattern1 = Pattern.compile(regex_prefix);
                Matcher matcher1 = pattern1.matcher(groupName);
                if (matcher1.matches()) {
                    flag1 = true;
                }
            }
            if (var2.contains(groupName)) {
                flag2 = true;
            }
            if (var3.contains(groupName)) {
                flag3 = true;
            }
        }
        if (flag1 && flag2) {
            return true;
        }
        if (flag2 && flag3) {
            return true;
        }
        return false;
    }

    /**
     * 母公司财务表头
     *
     * @param text
     * @return
     */
    public boolean isMGSCW(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"母公司", "本部资产负债表", "本部财务报表", "资产构成情况", "资产结构", "母公司资产负债表", "资产负债表\\(本部\\)", "资产负债表(本部)", "资产负债表(母公司)", "资产负债表\\(母公司\\)"};
//        String regex = "(((图)?表)|(母公司资产负债表)|(资产负债表\\(母公司\\)))";
        String regex = "(^((图)?表)|(" + joinSynonyms(synonyms) + ")|(单位))";
        boolean flag1 = false;
        boolean flag2 = false;
        boolean flag3 = false;

        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        List<String> var1 = new ArrayList<>(Arrays.asList(new String[]{"表", "图表"}));
        List<String> var2 = new ArrayList<>(Arrays.asList(synonyms));
        List<String> var3 = new ArrayList<>(Arrays.asList(new String[]{"单位"}));

        while (matcher.find()) {
            if (var1.contains(matcher.group())) {
                flag1 = true;
            }
            if (var2.contains(matcher.group())) {
                flag2 = true;
            }
            if (var3.contains(matcher.group())) {
                flag3 = true;
            }
        }
        if (flag1 && flag2) {
            return true;
        }

        if (flag2 && flag3) {
            return true;
        }
        String regex1 = "\\(一\\)[\\u0391-\\uFFE5]{0,}\\s{0,}$";
        pattern = Pattern.compile(regex1);
        matcher = pattern.matcher(text);
        if (matcher.matches()) {
            return true;
        }
        return false;
    }

    public boolean isDJG_UNIT(String text) {
        String regex = "[一二三四五六七八九十0-9]{1,2}\\s?[人|名]{1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }


    /**
     * 董监高
     *
     * @param text
     * @return
     */
    public boolean isDJG(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"董事", "董事会", "监事会", "监事", "高级管理", "高管"};
        String regex = "(^((图)?表)|(" + joinSynonyms(synonyms) + "))";
//        String regex = "((((图)?表)\\s?\\d{1,2}\\-\\d{1,2})|(" + joinSynonyms(synonyms) + "))";
        boolean flag1 = false;
        boolean flag2 = false;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        List<String> var1 = new ArrayList<>(Arrays.asList(new String[]{"表", "图表"}));
        List<String> var2 = new ArrayList<>(Arrays.asList(synonyms));
        while (matcher.find()) {
            if (var1.contains(matcher.group())) {
                flag1 = true;
            }

            if (var2.contains(matcher.group())) {
                flag2 = true;
            }
        }
        if (flag1 && flag2) {
            return true;
        }
        return false;
    }


    private String findDateFormatSplitChar(String text) {
        String regex = "(\\/|或)";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.find()) {
            return matcher.group();
        }
        return null;
    }

    public String preProcessDate(String text) {
        String splitChar = findDateFormatSplitChar(text);
        if (!StringUtils.isEmpty(splitChar)) {
            int slashIndex = text.indexOf(splitChar);
            if (slashIndex > 1) {
                String[] splits = text.split("\\/");
                if (splits.length == 2) {
                    text = text.substring(0, slashIndex);
                }
            }
        }
        return text;
    }

    /**
     * 2018-12-31
     * 2018年度
     * 2018年末
     * 2018.12.31
     * 2018/12/31
     * 2018年12月31日
     * 2015年
     *
     * @param text
     * @return
     */
    public boolean isZCFZ_NB(String text) {
        String regex = "((20\\d{2}\\s?[./\\-年]{1}\\s?12\\s?[./\\-月]{1}\\s?31\\s?[日]?)|(20\\d{2}\\s?[年]?([度|末]?)))";
//        String regex1 = "((20\\d{2}\\-\\d{1,2}-\\d{1,2})|(20\\d{2}\\/\\d{1,2}\\/\\d{1,2}))";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text.trim());

        if (matcher.matches()) {
            return true;
        }
//        if (!matcher.matches()) {
//            pattern = Pattern.compile(regex1);
//            matcher = pattern.matcher(text);
//            return matcher.matches();
//        }
        return Boolean.FALSE;
    }

    /**
     * 2018-03-31
     * 2018.03.31
     * 2018/3/31
     * 2018年3月31日
     * 2018年1季度
     * 2018年一季度
     * 2017年9月
     * 2018年3月末kill
     * 2018年1-3月
     *
     * @param text
     * @return
     */
    public boolean isZCFZ_JB(String text) {
//        String regex = "((20\\d{2}\\s?[./\\-年]{1}\\s?0?[1369]{1}\\s?[./\\-月]{1}\\s?3[01]{1}\\s?[日]?)|(20\\d{2}\\s?年\\s?\\.?((0?[1369]{1}\\s?([\\-|\\~]\\d{1,2})?\\s?(月[末]?)?)|([一二三123]{1}季度))))";
        String regex = "((20\\d{2}\\s?[./\\-年]{1}\\s?0?[1369]{1}\\s?[./\\-月]{1}\\s?3[01]{1}\\s?[日]?)|(20\\d{2}\\s?[年]?\\s?\\.?((0?[1369]{1}\\s?([\\-|\\~]\\d{1,2})?\\s?(月[末]?)?)|([一二三123]{1}季度))))";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text.trim());
        return matcher.matches();
    }


    public String joinSynonyms(String[] synonyms, String... coreSynonyms) {
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < synonyms.length; i++) {
            stringBuilder.append(synonyms[i]);
            if (i < synonyms.length - 1) {
                stringBuilder.append("|");
            }
        }
        return stringBuilder.toString();
    }

    public boolean isCWZB_CZNL(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"偿债能力", "偿债", "偿债指标", "合并口径财务指标表", "财务指标", "主要财务指标"};
        String regex = "(^((图)?表)|(" + joinSynonyms(synonyms) + "))";
        boolean flag1 = false;
        boolean flag2 = false;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        List<String> var1 = new ArrayList<>(Arrays.asList(new String[]{"表", "图表"}));
        List<String> var2 = new ArrayList<>(Arrays.asList(synonyms));
        while (matcher.find()) {
            if (var1.contains(matcher.group())) {
                flag1 = true;
            }
            if (var2.contains(matcher.group())) {
                flag2 = true;
            }
        }
        if (flag1 && flag2) {
            return true;
        }
        return false;
    }

    public boolean isCWZB_YLNL(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"盈利能力", "盈利", "经营业绩", "合并口径财务指标表", "财务指标", "盈利指标"};
        String regex = "(^((图)?表)|(" + joinSynonyms(synonyms) + "))";
        boolean flag1 = false;
        boolean flag2 = false;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        List<String> var1 = new ArrayList<>(Arrays.asList(new String[]{"表", "图表"}));
        List<String> var2 = new ArrayList<>(Arrays.asList(synonyms));
        while (matcher.find()) {
            if (var1.contains(matcher.group())) {
                flag1 = true;
            }
            if (var2.contains(matcher.group())) {
                flag2 = true;
            }
        }
        if (flag1 && flag2) {
            return true;
        }
        return false;
    }

    public boolean isCWZB_YYNL(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"营运能力", "经营效率", "营运效率", "运营效率", "周转率", "运营能力", "合并口径财务指标表", "财务指标", "资产周转能力"};
        String regex = "(^((图)?表)|(" + joinSynonyms(synonyms) + "))";//营运能力|经营效率|营运效率|运营效率
        boolean flag1 = false;
        boolean flag2 = false;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        List<String> var1 = new ArrayList<>(Arrays.asList(new String[]{"表", "图表"}));
        List<String> var2 = new ArrayList<>(Arrays.asList(synonyms));
        while (matcher.find()) {
            if (var1.contains(matcher.group())) {
                flag1 = true;
            }

            if (var2.contains(matcher.group())) {
                flag2 = true;
            }
        }
        if (flag1 && flag2) {
            return true;
        }
        return false;
    }

    /**
     * //TODO
     * 年报默认加12就可以了
     *
     * @param text
     * @return
     */
    public String extractZCFZ_NB(String text) {
        return extractZCFZ_NB_WITH_YEAR(text) + "12";
    }

    public String extractZCFZ_NB_WITH_YEAR(String text) {
        String regex = "(^201\\d{1})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.find()) {
            return matcher.group(0);
        }
        return null;
    }

    public String extractZCFZ_JB_WITH_YEAR(String text) {
        String regex = "(^201\\d{1})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.find()) {
            return matcher.group(0);
        }
        return null;
    }

    public String extractZCFZ_JB(String text) {
        text = text.replaceAll("\\s", "");
        String regex1 = "20\\d{2}\\s?[./\\-年]{1}\\s?0?[1369]{1}\\s?[./\\-月]{1}\\s?3[01]{1}\\s?[日]?";
        String regex2 = "20\\d{2}\\s?年\\s?((0?[1369]{1}\\s?([\\-\\~]\\d{1,2})?\\s?月[末]?))";
        String regex3 = "((20\\d{2}\\s?年\\s?)([一二三123]{1}季度))";
        Pattern pattern1 = Pattern.compile(regex1);
        Matcher matcher1 = pattern1.matcher(text);
        Pattern pattern2 = Pattern.compile(regex2);
        Matcher matcher2 = pattern2.matcher(text);
        Pattern pattern3 = Pattern.compile(regex3);
        Matcher matcher3 = pattern3.matcher(text);
        StringBuilder stringBuilder = new StringBuilder();
        if (matcher1.matches()) {
            String dateStr = matcher1.group();
            try {
                dateStr = dateStr.replaceAll("[./\\-年月]", "-");
                dateStr = dateStr.replaceAll("[日]", "");
                Date date = DateUtils.parseDate(dateStr, "yyyy-MM-dd");
                GregorianCalendar gregorianCalendar = new GregorianCalendar();
                gregorianCalendar.setTime(date);
                stringBuilder.append(gregorianCalendar.get(GregorianCalendar.YEAR)).append("0").append(gregorianCalendar.get(GregorianCalendar.MONTH) + 1);
            } catch (Exception e) {
                logger.error(e.getMessage(), e);
            }
        } else if (matcher2.matches()) {
            String dateStr = matcher2.group();
            if (dateStr.indexOf("-") > 0 || dateStr.indexOf("~") > 0) {
                dateStr = dateStr.replaceAll("\\d{1}[\\-|\\~]{1}", "");
            }
            try {
                dateStr = dateStr.replaceAll("[./\\-末]", "");
                Date date = DateUtils.parseDate(dateStr, "yyyy年MM月");
                GregorianCalendar gregorianCalendar = new GregorianCalendar();
                gregorianCalendar.setTime(date);
                stringBuilder.append(gregorianCalendar.get(GregorianCalendar.YEAR)).append("0").append(gregorianCalendar.get(GregorianCalendar.MONTH) + 1);
            } catch (Exception e) {
                logger.error(e.getMessage(), e);
            }
        } else if (matcher3.matches()) {
            String year = matcher3.group(2);
            {
                Pattern pattern = Pattern.compile("\\d{4}");
                Matcher matcher4 = pattern.matcher(year);
                if (matcher4.find()) {
                    year = matcher4.group();
                }
            }
            String season = matcher3.group(3);
            stringBuilder = new StringBuilder(year);
            switch (season) {
                case "1季度":
                case "一季度":
                    stringBuilder.append("03");
                    break;
                case "2季度":
                case "二季度":
                    stringBuilder.append("06");
                    break;
                case "三季度":
                case "3季度":
                    stringBuilder.append("09");
                    break;
            }
        }
        return stringBuilder.toString();
    }

    public boolean isYYSR(String text) {
        String[] synonyms = new String[]{"营业收入", "主营业务收入", "分板块收入", "营业总收入", "主营业收入"};
        String regex = "(^((图)?表)|(" + joinSynonyms(synonyms) + "))";
        boolean flag1 = false;
        boolean flag2 = false;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        List<String> var1 = new ArrayList<>(Arrays.asList(new String[]{"表", "图表"}));
        List<String> var2 = new ArrayList<>(Arrays.asList(synonyms));
        while (matcher.find()) {
            if (var1.contains(matcher.group())) {
                flag1 = true;
            }

            if (var2.contains(matcher.group())) {
                flag2 = true;
            }
        }
        if (flag1 && flag2) {
            return true;
        }
        return false;
    }

    public boolean isYYCB(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"营业成本", "主营业务成本", "分板块成本", "业务成本", "主营业成本"};
        String regex = "(^((图)?表)|(" + joinSynonyms(synonyms) + "))";
        boolean flag1 = false;
        boolean flag2 = false;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        List<String> var1 = new ArrayList<>(Arrays.asList(new String[]{"表", "图表"}));
        List<String> var2 = new ArrayList<>(Arrays.asList(synonyms));
        while (matcher.find()) {
            if (var1.contains(matcher.group())) {
                flag1 = true;
            }

            if (var2.contains(matcher.group())) {
                flag2 = true;
            }
        }
        if (flag1 && flag2) {
            return true;
        }
        return false;
    }

    public boolean isMLR(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"营业毛利润", "主营业务毛利润", "主营业务利润", "分板块毛利润", "毛利润", "毛利情况"};
        String regex = "(^((图)?表)|(" + joinSynonyms(synonyms) + "))";
        boolean flag1 = false;
        boolean flag2 = false;

        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        List<String> var1 = new ArrayList<>(Arrays.asList(new String[]{"表", "图表"}));
        List<String> var2 = new ArrayList<>(Arrays.asList(synonyms));
        while (matcher.find()) {
            if (var1.contains(matcher.group())) {
                flag1 = true;
            }

            if (var2.contains(matcher.group())) {
                flag2 = true;
            }
        }
        if (flag1 && flag2) {
            return true;
        }
        return false;
    }

    public boolean isMLL(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"毛利率", "分板块毛利率"};
        String regex = "(^((图)?表)|(" + joinSynonyms(synonyms) + "))";
        boolean flag1 = false;
        boolean flag2 = false;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        List<String> var1 = new ArrayList<>(Arrays.asList(new String[]{"表", "图表"}));
        List<String> var2 = new ArrayList<>(Arrays.asList(synonyms));
        while (matcher.find()) {
            if (var1.contains(matcher.group())) {
                flag1 = true;
            }

            if (var2.contains(matcher.group())) {
                flag2 = true;
            }
        }
        if (flag1 && flag2) {
            return true;
        }
        return false;
    }

    public boolean isXYPJ(String text) {
        String regex = "[一二三四五六七八九十]{0,1}\\、\\s{0,}[\\u0391-\\uFFE5]{0,}(信用评级情况|评级情况)";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public String extractPageNumber(String text) {
        String regex = "(\\d{1,})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.find()) {
            return matcher.group(0);
        }
        return null;
    }


    /**
     * 董监高-姓名
     *
     * @return
     */
    public boolean isDJG_XM(String text) {
        String regex = "(姓名)";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    /**
     * 董监高-职务
     *
     * @return
     */
    public boolean isDJG_ZW(String text) {
        String regex = "(职务|现任职务|现岗位职务)";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isYXZW(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"用途明细", "有息债务借款", "偿还债券明细", "到期债务", "募集资金用途", "到期债券情况", "资金分配", "偿还贷款","贷款情况", "借款", "借款明细", "有息债务"};
        String regex = "(^((图)?表)|(" + joinSynonyms(synonyms) + "))";//营运能力|经营效率|营运效率|运营效率
        boolean flag1 = false;
        boolean flag2 = false;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        List<String> var1 = new ArrayList<>(Arrays.asList(new String[]{"表", "图表"}));
        List<String> var2 = new ArrayList<>(Arrays.asList(synonyms));
        while (matcher.find()) {
            if (var1.contains(matcher.group())) {
                flag1 = true;
            }
            if (var2.contains(matcher.group())) {
                flag2 = true;
            }
        }
        if (flag1 && flag2) {
            return true;
        }
        return false;
    }

    public boolean isYWGGC(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"已完工"};
        String regex = "(^((图)?表)|(" + joinSynonyms(synonyms) + "))";
        boolean flag1 = false;
        boolean flag2 = false;

        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        List<String> var1 = new ArrayList<>(Arrays.asList(new String[]{"表", "图表"}));
        List<String> var2 = new ArrayList<>(Arrays.asList(synonyms));
        while (matcher.find()) {
            if (var1.contains(matcher.group())) {
                flag1 = true;
            }

            if (var2.contains(matcher.group())) {
                flag2 = true;
            }
        }
        if (flag1 && flag2) {
            return true;
        }
        return false;

    }

    /**
     * 在建项目
     *
     * @return
     */
    public boolean isZJXM(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"在建项目", "在建工程", "在建"};
        String regex = "(^[图|表]{1,2}|(" + joinSynonyms(synonyms) + "))";
        boolean flag1 = false;
        boolean flag2 = false;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        List<String> var1 = new ArrayList<>(Arrays.asList(new String[]{"表", "图表", "图"}));
        List<String> var2 = new ArrayList<>(Arrays.asList(synonyms));
        while (matcher.find()) {
            if (var1.contains(matcher.group())) {
                flag1 = true;
            }

            if (var2.contains(matcher.group())) {
                flag2 = true;
            }
        }
        if (flag1 && flag2) {
            return true;
        }
        return false;
    }


    /**
     * 财务风险说明标题验证
     *
     * @param text
     * @return
     */
    public boolean isCWFX(String text) {
        String regex = "(\\(一\\)财务风险)";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    /**
     * 财务风险说明标题验证
     *
     * @param text
     * @return
     */
    public boolean isCWFX_KM(String text) {
        String regex = "\\d{1,2}[、|.]{0,}\\s{0,}[\\u0391-\\uFFE5]{0,}风险$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }


    public boolean isZCFZ_JE(String text) {
        String regex = "\\d{1,}\\.{0,}[0-9]{0,2}\\s{0,}(万元|亿元|元)";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isDWDB_JE(String text) {
        String regex = "(人民币|金额){0,1}\\s{0,}[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(万元|亿元|元){0,1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }


    public boolean isSXZC(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"受限资产", "资产质押", "抵押", "质押", "受限制情况", "质押情况", "资产抵押", "资产受限", "抵质押资产", "质押、抵押", "抵押资产", "受到限制的资产", "受限货币", "受限制资产", "资产抵、质押", "资金受限", "抵押贷款", "抵质押"};
        String regex = "(^((图)?表)|(" + joinSynonyms(synonyms) + "))";
        boolean flag1 = false;
        boolean flag2 = false;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        List<String> var1 = new ArrayList<>(Arrays.asList(new String[]{"表", "图表"}));
        List<String> var2 = new ArrayList<>(Arrays.asList(synonyms));
        while (matcher.find()) {
            if (var1.contains(matcher.group())) {
                flag1 = true;
            }
            if (var2.contains(matcher.group())) {
                flag2 = true;
            }
        }
        if (flag1 && flag2) {
            return true;
        }
        return false;
    }

    public boolean isDWDB(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"对外担保"};
        String regex = "(^((图)?表)|(" + joinSynonyms(synonyms) + "))";
        boolean flag1 = false;
        boolean flag2 = false;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        List<String> var1 = new ArrayList<>(Arrays.asList(new String[]{"表", "图表"}));
        List<String> var2 = new ArrayList<>(Arrays.asList(synonyms));
        while (matcher.find()) {
            if (var1.contains(matcher.group())) {
                flag1 = true;
            }
            if (var2.contains(matcher.group())) {
                flag2 = true;
            }
        }
        if (flag1 && flag2) {
            return true;
        }
        return false;
    }

    public boolean isSXZC_JE(String text) {
        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(万元|亿元|元){0,}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    /**
     * 近三年及一期
     *
     * @param text
     * @return
     */
    public boolean isJSNJYQ(String text) {
        String regex = "(近三年及一期)";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }


    public boolean isDSH(String text) {
        String regex = "([一|二|三|四|五|六|七|八|九|1-9]){1}[名|人]{0,1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }


    public boolean isKJKMFX_ZCFZ(String text) {
        String regex = "[一|二|三|四|五|六|七|八|九]{1}\\、{1}\\s{0,}[\\u0391-\\uFFE5]{0,}(科目|指标){1}[\\u0391-\\uFFE5]{0,}(分析|情况){0,1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    /**
     * 会计科目分析标题
     *
     * @param text
     * @return
     */
    public boolean isKJKMFX_KM(String text) {
        String regex = "\\({0,1}\\d{1,2}\\){0,1}\\、{0,1}\\s{0,}[\\u0391-\\uFFE5]{0,}\\s{0,}$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isHD_FDSBPJLYXSS(String text) {
        String regex = "((([0-9]{0,3}\\,{1,}){0,}([0-9]{1,3}){1,}\\.{0,}[0-9]{0,2})\\s{0,}(小时){1})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isHD_FDSBPJLYXSS_UNIT(String text) {
        String regex = "((([0-9]{0,3}\\,{1,}){0,}([0-9]{1,3}){1,}\\.{0,}[0-9]{0,2})\\s{0,}(小时){1})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isMT_SYKCCL(String text) {
//        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(万吨|亿吨){1}";
        String regex = "((([0-9]{0,3}\\,{1,}){0,}([0-9]{1,3}){1,}\\.{0,}[0-9]{0,2})\\s{0,}(万吨|亿吨){1})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isMT_MTCL(String text) {
//        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(万吨|亿吨){1}";
        String regex = "((([0-9]{0,3}\\,{1,}){0,}([0-9]{1,3}){1,}\\.{0,}[0-9]{0,2})\\s{0,}(万吨|亿吨){1})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isMT_XSJG(String text) {
        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(小时){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isMT_SCCB(String text) {
        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(小时){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isSX_YSYSX(String text) {
        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(万元|亿元){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isSX_SXZE(String text) {
        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(万元|亿元){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isGSGL_KYL(String text) {
//        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(亿人次|万人次|亿人|万人){1}";
        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(亿人次|万人次|亿人|万人){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isGSGL_KYL_UNIT(String text) {
//        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(亿人次|亿人|亿人|万人){1}";
//        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(亿人次|亿人|亿人|万人){1}";
        String regex = "((([0-9]{0,3}\\,{1,}){0,}([0-9]{1,3}){1,}\\.{0,}[0-9]{0,2})\\s{0,}(亿人次|亿人|亿人|万人){1})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }


    public boolean isGSGL_KYZZL(String text) {
        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(亿人公里|万人公里){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isGSGL_KYZZL_UNIT(String text) {
        String regex = "((([0-9]{0,3}\\,{1,}){0,}([0-9]{1,3}){1,}\\.{0,}[0-9]{0,2})\\s{0,}(亿人公里|万人公里){1})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isGSGL_HYL(String text) {
        String regex = "((([0-9]{0,3}\\,{1,}){0,}([0-9]{1,3}){1,}\\.{0,}[0-9]{0,2})\\s{0,}(亿吨|万吨){1})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isGSGL_HYL_UNIT(String text) {
        String regex = "((([0-9]{0,3}\\,{1,}){0,}([0-9]{1,3}){1,}\\.{0,}[0-9]{0,2})\\s{0,}(亿吨|万吨){1})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isGSGL_HYZZL(String text) {
        String regex = "((([0-9]{0,3}\\,{1,}){0,}([0-9]{1,3}){1,}\\.{0,}[0-9]{0,2})\\s{0,}(亿吨公里|万吨公里){1})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isGSGL_HYZZL_UNIT(String text) {
        String regex = "((([0-9]{0,3}\\,{1,}){0,}([0-9]{1,3}){1,}\\.{0,}[0-9]{0,2})\\s{0,}(亿吨公里|万吨公里){1})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }


    /**
     * 产能利用率
     *
     * @param text
     * @return
     */
    public boolean isGT_CNLYL(String text) {
        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(%){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isGT_CNLYL_UNIT(String text) {
        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(%){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    /**
     * 产量规模
     *
     * @param text
     * @return
     */
    public boolean isGT_CLGM(String text) {
        String regex = "((([0-9]{0,3}\\,{1,}){0,}([0-9]{1,3}){1,}\\.{0,}[0-9]{0,2})\\s{0,}(万吨|亿吨){1})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isGT_CLGM_UNIT(String text) {
        String regex = "((([0-9]{0,3}\\,{1,}){0,}([0-9]{1,3}){1,}\\.{0,}[0-9]{0,2})\\s{0,}(万吨|亿吨){1})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    /**
     * 人均产钢量
     *
     * @param text
     * @return
     */
    public boolean isGT_RJCGL(String text) {
        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(%){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isGT_RJCGL_UNIT(String text) {
        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(%){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public String replaceAmtComma(String text) {
        String regex = "([0-9]{1,3}\\,{0,}){1,}\\.{0,}[0-9]{0,2}\\s{0,}(万元|亿元){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher m = pattern.matcher(text);
        StringBuffer sb = new StringBuffer();
        while (m.find()) {
            m.appendReplacement(sb, m.group().replace(",", ""));
            System.out.println(m.group());
        }
        m.appendTail(sb);
        return sb.toString();
    }


    public boolean isSN_SLCN(String text) {
        String regex = "((([0-9]{0,3}\\,{1,}){0,}([0-9]{1,3}){1,}\\.{0,}[0-9]{0,2})\\s{0,}(万吨|亿吨){1})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isSN_XKGMJ(String text) {
        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(万平方米){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isSN_CNLYL(String text) {
        String regex = "[0-9]{1,2}\\.{0,}[0-9]{0,2}\\s{0,}(%){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    /**
     * 房地产-签约销售面积
     *
     * @param text
     * @return
     */
    public boolean isFDC_QYXSMJ(String text) {
        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(万平方米){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isFDC_QYXSMJ_UNIT(String text) {
        String regex = "(([0-9]{1,3}\\,{0,}){1,}\\.{0,}[0-9]{0,2}\\s{0,}(万平方米){1})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    /**
     * 房地产-销售金额
     *
     * @param text
     * @return
     */
    public boolean isFDC_XSJE(String text) {
        String regex = "([0-9]{1,3}\\,{0,}){1,}\\.{0,}[0-9]{0,2}\\s{0,}(万元|亿元){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isFDC_XSJE_UNIT(String text) {
        String regex = "([0-9]{1,3}\\,{0,}){1,}\\.{0,}[0-9]{0,2}\\s{0,}(万元|亿元){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    /**
     * 待售面积占比
     *
     * @param text
     * @return
     */
    public boolean isFDC_DSMJZB(String text) {
        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(%){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }


    public boolean isFXR_END(String text) {
        String regex = "[二|三|四|五|六|七|八|九|十]{1,2}\\、{0,1}\\s{0,}[\\u0391-\\uFFE5]{0,}$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isNumberPage(String text) {
        if (StringUtils.isEmpty(text)) {
            return false;
        }
        text = text.replaceAll("\\s{0,}", "");
        String regex = "\\d{1,3}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isFDC_DSMJZB_UNIT(String text) {
        String regex = "[0-9]{0,2}\\s{0,}(%){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    /**
     * 土地储备规划建筑面积
     *
     * @param text
     * @return
     */
    public boolean isFDC_TDCBGHJZMJ(String text) {
        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(平方米|万平方米){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isFDC_TDCBGHJZMJ_UNIT(String text) {
        String regex = "[0-9]{1,}\\.{0,}[0-9]{0,2}\\s{0,}(平方米|万平方米){1}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public String replaceCRLF(String text) {
        return text.replaceAll("\\r", "");
    }

    public boolean isFXTK_END(String text) {
        String regex = "[一|二|三|四|五|六]{1}\\、{0,1}\\s{0,}[\\u0391-\\uFFE5]{0,}发行安排$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }


    public boolean isZXQK_CATALOG(String text) {
        String regex = "[一|二|三|四|五|六|七|八]{1}\\、{0,1}\\s{0,}[\\u0391-\\uFFE5]{0,}$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isFXRJBQK_CATALOG(String text) {
        String regex = "[一|二|三|四|五|六|七|八|九|十]{1,2}\\、{0,1}\\s{0,}[\\u0391-\\uFFE5]{0,}$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    /**
     * @param text
     * @return
     */
    public boolean isFXTK_JZBJJDAP(String text) {
        String regex = "\\([一|二|三|四|五|六|七|八|九|十]{1,2}\\)\\、{0,1}\\s{0,}[\\u0391-\\uFFE5]{0,}(簿记建档)[\\u0391-\\uFFE5]{0,}$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isFXTK_JKJSAP(String text) {
        String regex = "\\([一|二|三|四|五|六|七|八|九|十]{1,2}\\)\\、{0,1}\\s{0,}[\\u0391-\\uFFE5]{0,}(缴款[和]?结算)[\\u0391-\\uFFE5]{0,}$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public boolean isFXTK_SSLTAP(String text) {
        String regex = "\\([一|二|三|四|五|六|七|八|九|十]{1,2}\\)\\、{0,1}\\s{0,}[\\u0391-\\uFFE5]{0,}(上市流通)[\\u0391-\\uFFE5]{0,}$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }


    public boolean isFXTK_CATALOG(String text) {
        String regex = "\\([一|二|三|四|五|六|七|八|九|十]{1,2}\\)\\、{0,1}\\s{0,}[\\u0391-\\uFFE5]{0,}$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public String queryThousandSeparator(String text) {
        String regex = "(((\\d{4,}\\.{1,}\\d{0,4})|([^\\.]\\d{4,})){1}\\s{0,}(万元|亿元))";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        while (matcher.find()) {
            return matcher.group();
        }
        return null;
    }

    public boolean isAmtUnit(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"万元/%", "亿元,%","亿元，%","万元", "亿元", "%，万元","%,万元", "元", "次\\/年", "次", "人民币万元", "%、倍", "%、万元、倍", "人民币亿元", "次/每年", "平方米、万元", "次,年"};
        String regex = "((单位\\:{0,1}\\s?)(" + joinSynonyms(synonyms) + ")?[、%]{0,2})";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        return matcher.matches();
    }

    public String getUnitType(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"万元", "亿元", "元", "千元"};
        String regex = "((单位\\:{0,1}\\s?)|(" + joinSynonyms(synonyms) + ")?)";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        String unitName = synonyms[0];//缺省值
        while (matcher.find()) {
            unitName = matcher.group();
            if (ArrayUtils.contains(synonyms, unitName)) {
                break;
            }
        }
        return unitName;
    }

    /**
     * 在建项目表格单位识别
     *
     * @param text
     * @return
     */
    public boolean isZJXM_UNIT(String text, String... coreSynonyms) {
        String[] synonyms = new String[]{"亿元、万平方米", "万平方米、%、亿元", "万平方米、亿元", "亿元"};
        String regex = "(单位\\s?\\:{0,1}\\s?(" + joinSynonyms(synonyms) + "))";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.matches()) {
            return true;
        }
        return false;
    }


    public boolean isTableNameFormat(String text) {
        String regex = "^((图)?表\\s{0,}\\d{1,2}\\s?[\\-\\.]{1}\\s?\\d{1,2}(\\s?\\-?\\s?\\d?))";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.find()) {
            return true;
        }
        return false;
    }

    public boolean isTableUnitFormat(String text) {
        String regex = "^(单位)";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.find()) {
            return true;
        }
        return false;
    }

    public boolean isHJFormat(String text) {
        String regex = "(合计|总计|小计)";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.matches()) {
            return true;
        }
        return false;
    }

    public String replaceFXJG_Prefix(String text) {
        String regex = "^(\\(?[一二三四五六七八九十0-9]{0,2}\\、?\\)?)";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (matcher.find()) {
            return matcher.replaceFirst("");
        }
        return text;
    }


    private static List<String> statementList = new ArrayList<>();

    static {
        statementList.add("在本募集说明书中，除非文中另有所指，下列词语具有如下含义");
        statementList.add("在本募集说明书中，除非上下文另有规定，下列词汇具有以下含义");
    }

    public List<String> getStatementList() {
        return statementList;
    }


}


